package com.sqfw.project.wpReport.controller;

import com.sqfw.common.utils.poi.ExcelUtil;
import com.sqfw.framework.aspectj.lang.annotation.Log;
import com.sqfw.framework.aspectj.lang.enums.BusinessType;
import com.sqfw.framework.web.controller.BaseController;
import com.sqfw.framework.web.domain.AjaxResult;
import com.sqfw.framework.web.page.TableDataInfo;
import com.sqfw.project.wp.domain.WpInfo;
import com.sqfw.project.wpReport.domain.SeatWorkReport;
import com.sqfw.project.wpReport.domain.WpInfoBusiness;
import com.sqfw.project.wpReport.service.IWpInfoBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 业务统计Controller
 *
 * @author lx
 * @date 2023-07-17
 */
@RestController
@RequestMapping("/wpReport/wpInfoBusiness")
public class WpInfoBusinessController extends BaseController {
    @Autowired
    private IWpInfoBusinessService wpInfoBusinessService;

    /**
     * 查询业务统计列表
     */
    @PreAuthorize("@ss.hasPermi('getWpInfoBusinessList')")
    @GetMapping("/getWpInfoBusinessList")
    public AjaxResult getWpInfoBusinessList(WpInfo wpInfo) {
        List<WpInfoBusiness> list = wpInfoBusinessService.selectWpInfoBusinessList(wpInfo);
        return AjaxResult.success(list);
    }

    /**
     * 导出业务统计列表
     */
    @Log(title = "业务统计", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('wpInfoBusiness:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, WpInfo wpInfo) {
        List<WpInfoBusiness> list = wpInfoBusinessService.selectWpInfoBusinessList(wpInfo);
        ExcelUtil<WpInfoBusiness> util = new ExcelUtil<WpInfoBusiness>(WpInfoBusiness.class);
        util.exportExcel(response, list, "业务统计数据");
    }

    /**
     * 业务统计列表深挖查询工单
     * @param wpInfo
     * @return
     */
    @PreAuthorize("@ss.hasPermi('selectWpInfoByClassAndWpType')")
    @GetMapping("/selectWpInfoByClassAndWpType")
    public TableDataInfo selectWpInfoByClassAndWpType(WpInfo wpInfo) {
        startPage();
        List<WpInfo> wpInfos = wpInfoBusinessService.selectWpInfoByClassAndWpType(wpInfo);
        return getDataTable(wpInfos);

    }


}

